import CommentForm from '@components/CommentForm/CommentForm'; import CommentsList from '@components/CommentsList/CommentsList'; import Layout from '@components/Layouts/Layout'; import PostFooter from '@components/PostFooter/PostFooter'; import PostHeader from '@components/PostHeader/PostHeader'; import { t } from '@lingui/macro'; import { getAllPostsSlug, getPostBySlug } from '@services/graphql/queries'; import { NextPageWithLayout } from '@ts/types/app'; import { ArticleProps } from '@ts/types/articles'; import { loadTranslation } from '@utils/helpers/i18n'; import { GetStaticPaths, GetStaticProps, GetStaticPropsContext } from 'next'; import Head from 'next/head'; import { ParsedUrlQuery } from 'querystring'; import { ReactElement } from 'react'; const SingleArticle: NextPageWithLayout = ({ post }) => { const { author, comments, content, dates, intro, seo, subjects, thematics, title, } = post; return ( <> {seo.title}

{t`Comments`}

{t`Leave a comment`}

); }; SingleArticle.getLayout = function getLayout(page: ReactElement) { return {page}; }; interface PostParams extends ParsedUrlQuery { slug: string; } export const getStaticProps: GetStaticProps = async ( context: GetStaticPropsContext ) => { const translation = await loadTranslation( context.locale!, process.env.NODE_ENV === 'production' ); const { slug } = context.params as PostParams; const post = await getPostBySlug(slug); return { props: { post, translation, }, }; }; export const getStaticPaths: GetStaticPaths = async () => { const allSlugs = await getAllPostsSlug(); return { paths: allSlugs.map((post) => `/article/${post.slug}`), fallback: true, }; }; export default SingleArticle;